#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>

int main(int argc, char* argv[]){
	if(argc < 2){
		write(2, "Usage: ./file_reader <filename>\n", 33);
		return 1;
	}

	int fd = open(argv[1], O_RDONLY);
	if(fd == -1){
		perror("open failed");
		return 1;
	}

	char buf[1024];
	int bytes;
	while((bytes = read(fd, buf, sizeof(buf))) > 0){
		write(1, buf, bytes);
	}

	close(fd);
	return 0;
}
